package com.nm.web.convert;

import com.nm.orm.pojo.CategoryEntity;
import com.nm.service.output.CategoryOutput;
import com.nm.web.request.CategoryUpdateRequest;

/**
 * 功能说明：分类转换器
 * @return <br/>
 *         修改历史：<br/>
 *         1.[2017年02月12日上午17:03] 创建方法 by hw
 */
public class CategoryConvertor {

    public static CategoryOutput conv(CategoryEntity entity) {
        CategoryOutput output = new CategoryOutput();

        output.setId(entity.getOrderBy());
        output.setText(entity.getDescription());
        output.setCategoryId(entity.getId());

        return output;
    }

    public static CategoryEntity conv(CategoryUpdateRequest input) {
        CategoryEntity entity = new CategoryEntity();

        entity.setId(input.getId());
        entity.setName(input.getCategoryName());
        entity.setDescription(input.getDescription());
        entity.setKeywords(input.getKeywords());
        entity.setPid(input.getCategoryPid());
        entity.setOrderBy(input.getOrderBy());

        return entity;
    }
}
